package com.order.controller;

import com.common.entity.Shopcar;
import com.common.untils.CommonResult;
import com.order.service.IShopcarService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author xdl
 * @since 2022-08-31
 */
@RestController
@RequestMapping("/order/shopcar")
public class ShopcarController {
    @Autowired
   private IShopcarService iShopcarService;
    @PostMapping("selecByIdShopCar/{currentPage}/{pageSizes}")
    public CommonResult selecByIdShopCar(@PathVariable Integer currentPage, @PathVariable Integer pageSizes, HttpServletRequest request){
        String hometoken = request.getHeader("hometoken");
        return iShopcarService.selecByIdShopCar(currentPage,pageSizes,hometoken);
    }
    @PostMapping("/inset")
    public CommonResult inset(@RequestBody Shopcar shopcar, HttpServletRequest request){
        //获取token
        String hometoken = request.getHeader("hometoken");
        return iShopcarService.inset(shopcar,hometoken);
    }
    @PostMapping("/deleteById/{id}")
    public CommonResult deleteById(@PathVariable Integer id){
      return   iShopcarService.deleteById(id);
    }
}
